<template>
  <div class="main1 animate__animated animate__fadeInRightBig">
    <span class="register_title">验证码您的手机</span>
    <div class="phone_col">
      <span>手机号码</span>
      <div class="phone">
        <el-select placeholder="Select" style="width: 90px">
          <el-option label="Restaurant" value="1" />
          <el-option label="Order No." value="2" />
          <el-option label="Tel" value="3" />
        </el-select>
        <div class="phone_input">
          <el-input type="text" class="flex-1" maxlength="11" v-model="register.phone" />
          <span @click="getCode">获取验证码</span>
        </div>
      </div>
    </div>
    <div class="phone_code">
      <span>短信验证码</span>
      <verificationCode v-model:code="register.code" />
    </div>
    <Message />
    <label for="email">
      <span>Email</span>
      <el-input v-model="register.email"></el-input>
    </label>
    <label for="password">
      <span>密码</span>
      <div>
        <el-input :type="showPassword ? 'text' : 'password'" v-model="register.password"></el-input>
        <span class="ispassword iconfont" @click="showPassword = !showPassword"
          :class="showPassword ? 'icon-mimaxianshi' : 'icon-icon_794'"></span>
      </div>
    </label>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import Message from '@/components/message/index.vue';
import verificationCode from '@/components/verificationcode/index.vue';
import { IRegister } from '@/types/register';
import { sendCodeApi } from '@/api/userApi'
const { register } = defineProps<{ register: IRegister }>()

// 显示密码
const showPassword = ref(false)

/**
 * 获取验证码
 */
function getCode() {
  sendCodeApi(register.phone).then(res => {
    console.log(res);
  }).catch(error => error)
}

</script>


<style lang="scss" scoped>
.main1 {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 40px;
}

.register_title {
  font-weight: bold;
  font-size: 25px;
}

label {

  width: 450px;
  text-align: left;

  >span {
    color: #7D8592;
    display: inline-block;
    margin: 6px 0;
  }

  >div {
    position: relative;
  }
}

.ispassword {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 30px;
  height: 30px;
  font-size: 24px;
  line-height: 30px;
  transform: translateY(-50%);
}

.phone_col {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: left;
  width: 450px;
  gap: 10px;
  color: #7D8592;

  .phone {
    display: flex;
    gap: 20px;
  }

  .phone_input {
    position: relative;
    flex: 1;

    >span {
      color: #3F8CFF;
      position: absolute;
      top: 0;
      right: 15px;
      transform: translateY(32%);
      font-size: 16px;
      width: max-content;
    }

  }
}

.phone_code {
  display: flex;
  flex-direction: column;
  text-align: left;
  width: 450px;
  margin: 10px 0;
  gap: 10px;
  color: #7D8592;

}

.el-input {
  height: 40px;
}
</style>